//
//  FindView.m
//  WNZSSQ
//
//  Created by JDKJ on 2018/12/4.
//  Copyright © 2018年 JDKJ. All rights reserved.
//

#import "FindView.h"

@implementation FindView


- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        
        self.backgroundColor = [UIColor clearColor];
        
        /**
         全部
         */
        UILabel *allLable = [[UILabel alloc]init];
        allLable.text = @"全部";
        allLable.textColor = CSBlackColor1;
        allLable.font = [UIFont systemFontOfSize:16];
        self.allLable = allLable;
        [self addSubview:allLable];
        
        /**
         添加按钮
         */
        
        UIButton *addBtn = [UIButton buttonWithType:UIButtonTypeCustom];
        [addBtn setImage:[UIImage imageNamed:@"添加频道"] forState:UIControlStateNormal];
        addBtn.contentHorizontalAlignment = UIControlContentHorizontalAlignmentCenter;
        addBtn.imageView.contentMode = UIViewContentModeScaleAspectFill;
        
        addBtn.contentEdgeInsets = UIEdgeInsetsMake(10, 10, 10, 10);
        [self addSubview:addBtn];
        self.addBtn = addBtn;
        
        [self setConstraints];
        
    }
    return self;
    
}

-(void)setConstraints
{
    //设置约束条件
    
    /**
     全部
     */
    [self.allLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.left.mas_equalTo(self).offset(15);
        make.centerY.mas_equalTo(self);
        
    }];
    
    /**
     添加
     */
    [self.addBtn mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.right.mas_equalTo(self).offset(-20);
        make.centerY.mas_equalTo(self);
        
    }];
    
}

@end


#pragma mark - 发现类型1

@implementation FindViewCellOne

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.backgroundColor = [UIColor clearColor];
        
        /**
         图片
         */
        UIImageView *covImageView = [[UIImageView alloc]init];
        covImageView.image = PlaceHold;
        covImageView.contentMode = UIViewContentModeScaleAspectFill;
        covImageView.clipsToBounds = YES;
        self.covImageView = covImageView;
        [self addSubview:covImageView];
        
        
        /**
         内容
         */
        UILabel *titleLable = [[UILabel alloc]init];
        titleLable.text = @"这是一段很长的喂蚊子这是一段很长的喂蚊子这是一段很长的喂蚊子这是一段很长的喂蚊子这是一段很长的喂蚊子";
        titleLable.numberOfLines = 3;
        titleLable.textColor = CSBlackColor1;
        titleLable.font = [UIFont systemFontOfSize:17];
        self.titleLable = titleLable;
        [self addSubview:titleLable];
        
        /**
         相关名称
         */
        UILabel *aboutLable = [[UILabel alloc]init];
        aboutLable.text = @"相关名称";
        aboutLable.textColor = CSColorFromRGB(0x6B6763);
        aboutLable.font = SmallFont;
        self.aboutLable = aboutLable;
        [self addSubview:aboutLable];
        
        /**
         阅读量
         */
        UILabel *readCountLable = [[UILabel alloc]init];
        readCountLable.text = @"10.27w次阅读";
        readCountLable.textColor = CSColorFromRGB(0x6B6763);
        readCountLable.font = SmallFont;
        self.readCountLable = readCountLable;
        [self addSubview:readCountLable];
        
        [self setConstraints];
        
    }
    return self;
}

-(void)setConstraints
{
    //设置约束条件
    
    /**
     图片
     */
    [self.covImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self).offset(20);
        make.left.mas_equalTo(self).offset(15);
        make.bottom.mas_equalTo(self).offset(-20);
        make.height.mas_equalTo((SCREENWIDTH -30)/3*90/100);
        make.width.mas_equalTo((SCREENWIDTH -30)/3);
        
    }];
    
    /**
     内容
     */
    [self.titleLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.covImageView);
        make.left.mas_equalTo(self.covImageView.mas_right).offset(8);
        make.right.mas_equalTo(self).offset(-15);
        
    }];
    
    /**
     相关名称
     */
    [self.aboutLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.mas_equalTo(self.covImageView);
        make.left.mas_equalTo(self.covImageView.mas_right).offset(8);
        
    }];
    
    /**
     阅读量
     */
    [self.readCountLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.mas_equalTo(self.covImageView);
        make.left.mas_equalTo(self.aboutLable.mas_right).offset(19);
        make.right.mas_lessThanOrEqualTo(self).offset(15);
        
    }];
}

@end

#pragma mark - 发现类型2

@implementation FindViewCellTwo

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.backgroundColor = [UIColor clearColor];
        
        /**
         图片
         */
        UIImageView *covImageView = [[UIImageView alloc]init];
        covImageView.image = PlaceHold2;
        covImageView.contentMode = UIViewContentModeScaleAspectFill;
        covImageView.clipsToBounds = YES;
        self.covImageView = covImageView;
        [self addSubview:covImageView];
        
        
        /**
         内容
         */
        UILabel *titleLable = [[UILabel alloc]init];
        titleLable.text = @"这是一段很长的喂蚊子这是一段很长的喂蚊子这是一段很长的喂蚊子这是一段很长的喂蚊子这是一段很长的喂蚊子";
        titleLable.numberOfLines = 2;
        titleLable.textColor = CSBlackColor1;
        titleLable.font = [UIFont systemFontOfSize:17];
        self.titleLable = titleLable;
        [self addSubview:titleLable];
        
        /**
         相关名称
         */
        UILabel *aboutLable = [[UILabel alloc]init];
        aboutLable.text = @"相关名称";
        aboutLable.textColor = CSColorFromRGB(0x6B6763);
        aboutLable.font = SmallFont;
        self.aboutLable = aboutLable;
        [self addSubview:aboutLable];
        
        /**
         阅读量
         */
        UILabel *readCountLable = [[UILabel alloc]init];
        readCountLable.text = @"10.27w次阅读";
        readCountLable.textColor = CSColorFromRGB(0x6B6763);
        readCountLable.font = SmallFont;
        self.readCountLable = readCountLable;
        [self addSubview:readCountLable];
        
        [self setConstraints];
        
    }
    return self;
}

-(void)setConstraints
{
    //设置约束条件
    
    /**
     图片
     */
    [self.covImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.titleLable.mas_bottom).offset(9);
        make.left.mas_equalTo(self.titleLable);
        make.right.mas_equalTo(self).offset(-15);
        make.height.mas_equalTo((SCREENWIDTH -30)/35*19);
        
    }];
    
    /**
     内容
     */
    [self.titleLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self).offset(18);
        make.left.mas_equalTo(self).offset(15);
        make.right.mas_equalTo(self).offset(-15);
        
    }];
    
    /**
     相关名称
     */
    [self.aboutLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.covImageView.mas_bottom).offset(12);
        make.bottom.mas_equalTo(self).offset(-20);
        make.left.mas_equalTo(self.covImageView);
        
    }];
    
    /**
     阅读量
     */
    [self.readCountLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self.aboutLable);
        make.left.mas_equalTo(self.aboutLable.mas_right).offset(19);
        make.right.mas_lessThanOrEqualTo(self).offset(15);
        
    }];
}

@end

#pragma mark - 发现类型3

@implementation FindViewCellThire

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.backgroundColor = [UIColor clearColor];
        
        /**
         图片
         */
        UIImageView *covImageView = [[UIImageView alloc]init];
        covImageView.image = PlaceHold4;
        covImageView.contentMode = UIViewContentModeScaleAspectFill;
        covImageView.clipsToBounds = YES;
        self.covImageView = covImageView;
        [self addSubview:covImageView];
        
        /**
         图片2
         */
        UIImageView *covImageView3 = [[UIImageView alloc]init];
        covImageView3.image = PlaceHold6;
        covImageView3.contentMode = UIViewContentModeScaleAspectFill;
        covImageView3.clipsToBounds = YES;
        self.covImageView3 = covImageView3;
        [self addSubview:covImageView3];
        
        /**
         图片3
         */
        UIImageView *covImageView2 = [[UIImageView alloc]init];
        covImageView2.image = PlaceHold5;
        covImageView2.contentMode = UIViewContentModeScaleAspectFill;
        covImageView2.clipsToBounds = YES;
        self.covImageView2 = covImageView2;
        [self addSubview:covImageView2];
        
        
        /**
         内容
         */
        UILabel *titleLable = [[UILabel alloc]init];
        titleLable.text = @"这是一段很长的喂蚊子这是一段很长的喂蚊子这是一段很长的喂蚊子这是一段很长的喂蚊子这是一段很长的喂蚊子";
        titleLable.numberOfLines = 2;
        titleLable.textColor = CSBlackColor1;
        titleLable.font = [UIFont systemFontOfSize:17];
        self.titleLable = titleLable;
        [self addSubview:titleLable];
        
        /**
         相关名称
         */
        UILabel *aboutLable = [[UILabel alloc]init];
        aboutLable.text = @"相关名称";
        aboutLable.textColor = CSColorFromRGB(0x6B6763);
        aboutLable.font = SmallFont;
        self.aboutLable = aboutLable;
        [self addSubview:aboutLable];
        
        /**
         阅读量
         */
        UILabel *readCountLable = [[UILabel alloc]init];
        readCountLable.text = @"10.27w次阅读";
        readCountLable.textColor = CSColorFromRGB(0x6B6763);
        readCountLable.font = SmallFont;
        self.readCountLable = readCountLable;
        [self addSubview:readCountLable];
        
        [self setConstraints];
        
    }
    return self;
}

-(void)setConstraints
{
    //设置约束条件
    
    /**
     内容
     */
    [self.titleLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self).offset(18);
        make.left.mas_equalTo(self).offset(15);
        make.right.mas_equalTo(self).offset(-15);
        
    }];
    
     /**
     图片
     */
    CGFloat w = (SCREENWIDTH -50)/3;
    [self.covImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        
        make.top.mas_equalTo(self.titleLable.mas_bottom).offset(9);
        make.left.mas_equalTo(self.titleLable);
        make.width.mas_equalTo(w);
        make.height.mas_equalTo(w/4*3);
        
    }];
    
    /**
     图片2
     */
    [self.covImageView2 mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.titleLable.mas_bottom).offset(9);
        make.left.mas_equalTo(self.covImageView.mas_right).offset(10);
        make.width.mas_equalTo(w);
        make.height.mas_equalTo(w/4*3);
        
    }];
    
    /**
     图片3
     */
    [self.covImageView3 mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.titleLable.mas_bottom).offset(9);
        make.left.mas_equalTo(self.covImageView2.mas_right).offset(10);
        make.width.mas_equalTo(w);
        make.height.mas_equalTo(w/4*3);
        
    }];
    
    
    
    /**
     相关名称
     */
    [self.aboutLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.covImageView.mas_bottom).offset(12);
        make.bottom.mas_equalTo(self).offset(-20);
        make.left.mas_equalTo(self.covImageView);
        
    }];
    
    /**
     阅读量
     */
    [self.readCountLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.centerY.mas_equalTo(self.aboutLable);
        make.left.mas_equalTo(self.aboutLable.mas_right).offset(19);
        make.right.mas_lessThanOrEqualTo(self).offset(15);
        
    }];
}


@end



#pragma mark - 发现类型4

@implementation FindViewCellFour

- (instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    if (self = [super initWithStyle:style reuseIdentifier:reuseIdentifier]) {
        
        self.backgroundColor = [UIColor clearColor];
        
        /**
         图片
         */
        UIImageView *covImageView = [[UIImageView alloc]init];
        covImageView.image = PlaceHold3;
        covImageView.contentMode = UIViewContentModeScaleAspectFill;
        covImageView.clipsToBounds = YES;
        self.covImageView = covImageView;
        [self addSubview:covImageView];
        
        
        /**
         内容
         */
        UILabel *titleLable = [[UILabel alloc]init];
        titleLable.text = @"这是一段很长的喂蚊子这是一段很长的喂蚊子这是一段很长的喂蚊子这是一段很长的喂蚊子这是一段很长的喂蚊子";
        titleLable.numberOfLines = 3;
        titleLable.textColor = CSBlackColor1;
        titleLable.font = [UIFont systemFontOfSize:17];
        self.titleLable = titleLable;
        [self addSubview:titleLable];
        
        /**
         相关名称
         */
        UILabel *aboutLable = [[UILabel alloc]init];
        aboutLable.text = @"相关名称";
        aboutLable.textColor = CSColorFromRGB(0x6B6763);
        aboutLable.font = SmallFont;
        self.aboutLable = aboutLable;
        [self addSubview:aboutLable];
        
        /**
         阅读量
         */
        UILabel *readCountLable = [[UILabel alloc]init];
        readCountLable.text = @"10.27w次阅读";
        readCountLable.textColor = CSColorFromRGB(0x6B6763);
        readCountLable.font = SmallFont;
        self.readCountLable = readCountLable;
        [self addSubview:readCountLable];
        
        [self setConstraints];
        
    }
    return self;
}

-(void)setConstraints
{
    //设置约束条件
    
    /**
     图片
     */
    [self.covImageView mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self).offset(20);
        make.left.mas_equalTo(self).offset(15);
        make.bottom.mas_equalTo(self).offset(-20);
        make.height.mas_equalTo((SCREENWIDTH -30)/4);
        make.width.mas_equalTo((SCREENWIDTH -30)/3);
        
    }];
    
    /**
     内容
     */
    [self.titleLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.top.mas_equalTo(self.covImageView);
        make.left.mas_equalTo(self.covImageView.mas_right).offset(8);
        make.right.mas_equalTo(self).offset(-15);
        
    }];
    
    /**
     相关名称
     */
    [self.aboutLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.mas_equalTo(self.covImageView);
        make.left.mas_equalTo(self.covImageView.mas_right).offset(8);
        
    }];
    
    /**
     阅读量
     */
    [self.readCountLable mas_remakeConstraints:^(MASConstraintMaker *make) {
        
        make.bottom.mas_equalTo(self.covImageView);
        make.left.mas_equalTo(self.aboutLable.mas_right).offset(19);
        
    }];
}

@end
